package com.jzo2o.foundations.controller.consumer;

import com.jzo2o.common.model.Result;
import com.jzo2o.foundations.model.dto.response.ServeAggregationSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeAggregationTypeSimpleResDTO;
import com.jzo2o.foundations.model.dto.response.ServeCategoryResDTO;
import com.jzo2o.foundations.model.dto.response.ServeSimpleResDTO;
import com.jzo2o.foundations.service.IServeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController("consumerServeController")
@RequestMapping("/customer/serve")
@Api(tags = "用户端 - 区域下服务相关接口")
public class ServeController {
    @Resource
    private IServeService serveService;

    @GetMapping("/firstPageServeList")
    @ApiOperation("查询指定区域下上架的服务项目及分类")
    public List<ServeCategoryResDTO> firstPageServeList(Long regionId) {
        //查询首页服务分类项目列表
        return serveService.indexServeList(regionId);
    }

    @GetMapping("/hotServeList")
    @ApiOperation("查询精选推荐服务列表")
    public List<ServeAggregationSimpleResDTO> hotServeList(@RequestParam Long regionId) {
        //查询精选推荐内容
        return serveService.hotServeList(regionId);
    }

    @GetMapping("/{id}")
    @ApiOperation("查询热门服务详情")
    public ServeAggregationSimpleResDTO findHotServeInfoById(@PathVariable("id") Long id) {
        //查询热门服务详情
        return serveService.findHotServeInfoById(id);
    }

    @GetMapping("/serveTypeList")
    @ApiOperation("查询热门服务详情")
    public List<ServeAggregationTypeSimpleResDTO> serveTypeList(Long regionId) {
        //查询某个服务类型下的全部服务
        return serveService.serveTypeList(regionId);
    }

    //首页服务搜索
    @GetMapping("/search")
    public List<ServeSimpleResDTO> findServeList(String cityCode, Long serveTypeId, String keyword) {
        return serveService.findServeList(cityCode, serveTypeId, keyword);
    }
}